﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>监控管理中心</title>
    <link href="Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="Scripts/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <link href="Scripts/plugins/custom.css" rel="stylesheet" />
    <style type="text/css">
        .nav-md .container.body .right_col {
            padding-left: 10px;
        }

        .ms-controller {
            visibility: hidden;
        }
    </style>
</head>
<body class="nav-md ms-controller" ms-controller="indexvm">
    <div class="container body">
        <div class="main_container">
            <div class="col-md-3 left_col">
                <div class="left_col scroll-view">
                    <div class="navbar nav_title" style="border: 0;">
                        <a href="index.html" class="site_title"> <span style="font-size:20px">监控管理中心</span></a>
                    </div>
                    <div class="clearfix"></div>
                    <br />
                    <div style="border-bottom:dotted 1px #ffffff;padding-left:5px;padding-right:5px;"></div>
                    <!-- sidebar menu -->
                    <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
                        <div class="menu_section">
                            <!-- <h3>菜单</h3>-->
                            <ul class="nav side-menu">
                                <li>
                                    <a href="javascript:void(0);" ms-click="@OpenHome('indexpage.html')"><i class="fa fa-home"></i> 首页 </a>
                                </li>
                                <li ms-for="(index,el) in @muData">
                                    <a><i ms-class="['fa',(el.MenuIco?el.MenuIco:'fa-clone')]"></i>{{el.MenuTxt}}<span class="fa fa-chevron-down"></span></a>
                                    <ul class="nav child_menu">
                                        <li ms-for="(index2,im) in el.SubItem"><a href="javascript:void(0);" ms-click="@OpenUrl(im)">{{im.MenuTxt}}</a></li>
                                    </ul>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <!-- /sidebar menu -->
                </div>
            </div>
            <!-- top navigation -->
            <div class="top_nav">
                <div class="nav_menu">
                    <nav class="" role="navigation">
                        <div class="nav toggle" style="width:300px;">
                            <a id="menu_toggle"><i class="fa fa-bars"></i></a>
                            <span ms-visible="@newPageName">首页>{{@newPageName}}</span>
                        </div>
                        <ul class="nav navbar-nav navbar-right">
                            <li class="">
                                <a href="javascript:;" class="user-profile dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                    {{@UserModel.UserName}}
                                    <span class="fa fa-angle-down"></span>
                                </a>
                                <ul class="dropdown-menu dropdown-usermenu pull-right">
                                    <li><a href="javascript:;" ms-click="@ChangePwd()"> 修改密码</a></li>
                                    <li><a ms-click="@LoginOut()"><i class="fa fa-sign-out pull-right"></i>退出</a></li>
                                </ul>
                            </li>
                            <!--<li role="presentation" class="dropdown">
                                <a href="javascript:;" class="dropdown-toggle info-number" data-toggle="dropdown" aria-expanded="false">
                                    <i class="fa fa-envelope-o"></i>
                                    <span class="badge bg-green">6</span>
                                </a>
                                <ul id="menu1" class="dropdown-menu list-unstyled msg_list" role="menu">
                                    <li>
                                        <a>
                                            <span class="image"><img src="" alt="Profile Image" /></span>
                                            <span>
                                                <span>John Smith</span>
                                                <span class="time">3 mins ago</span>
                                            </span>
                                            <span class="message">
                                                Film festivals used to be do-or-die moments for movie makers. They were where...
                                            </span>
                                        </a>
                                    </li>
                                    <li>
                                        <div class="text-center">
                                            <a>
                                                <strong>See All Alerts</strong>
                                                <i class="fa fa-angle-right"></i>
                                            </a>
                                        </div>
                                    </li>
                                </ul>
                            </li>-->
                        </ul>
                    </nav>
                </div>
            </div>
            <!-- /top navigation -->
            <!-- page content -->
            <div class="right_col" role="main">

                <script type="text/javascript">


                    //iframe自动设置高度
                    function getIframeWindow(obj) {
                        return obj.contentWindow || obj.contentDocument.parentWindow;
                    }
                    function getIframeHeight(obj) {
                        var idoc = getIframeWindow(obj).document;
                        if (idoc.body) {
                            return Math.max(idoc.body.scrollHeight, idoc.body.offsetHeight);
                        } else if (idoc.documentElement) {
                            return Math.max(idoc.documentElement.scrollHeight, idoc.documentElement.offsetHeight);
                        }
                    }
                    function setleftHeight(obj) {
                        var leftiframe = document.getElementById(obj);
                        leftiframe.height = 10;
                        leftiframe.height = getIframeHeight(leftiframe);
                    }
                    function SetCwinHeight() {
                        var iframeid = document.getElementById("main"); //iframe id
                        iframeid.height = document.documentElement.clientHeight + 15 + "px";//先给一个够小的初值,然后再长高.

                        if (document.getElementById) {
                            if (iframeid && !window.opera) {
                                if (iframeid.contentDocument && iframeid.contentDocument.body.offsetHeight) {
                                    iframeid.height = iframeid.contentDocument.body.offsetHeight;
                                } else if (iframeid.Document && iframeid.Document.body.scrollHeight) {
                                    iframeid.height = iframeid.Document.body.scrollHeight;
                                }
                            }
                        }
                    }

                    function reinitIframe() {
                        var iframe = document.getElementById("main");
                        try {
                            var bHeight = iframe.contentWindow.document.body.scrollHeight;
                            var dHeight = iframe.contentWindow.document.documentElement.scrollHeight + 10;
                            var height = Math.min(bHeight, dHeight);
                            iframe.height = height;
                        } catch (ex) { }
                    }
                    setInterval(reinitIframe, 800);
                    document.onkeydown = function (ev) {
                        var oEvent = ev || event;
                        if (oEvent.keyCode == 116 && document.getElementById('main')) {
                            var rightF = document.getElementById('main');
                            var rightFobj = getIframeWindow(rightF);
                            rightFobj.document.location.reload();
                            if (!/firefox/i.test(window.navigator.userAgent)) oEvent.keyCode = 0;
                            oEvent.cancelBubble = true;
                            return false;
                        }
                        if (oEvent.keyCode == 8 && document.getElementById('main')) {
                            if (!/firefox/i.test(window.navigator.userAgent)) oEvent.keyCode = 0;
                            oEvent.cancelBubble = true;
                            return false;
                        }
                    };

                    function iFrameHeight() {
                        var ifm = document.getElementById("main");
                        var subWeb = document.frames ? document.frames["main"].document : ifm.contentDocument;
                        if (ifm != null && subWeb != null) {
                            ifm.height = 10;
                            ifm.height = subWeb.body.scrollHeight + 10;
                        }
                    }
                </script>
                <!--<div class="x_title">
                    <h6>首页>{{@newPageName}}</h6>

                    <div class="clearfix"></div>
                </div>-->
                <iframe id="main" name="main" marginwidth="0" onload="SetCwinHeight()" frameborder="0" ms-attr="{src:@nowPage}" scrolling="no" style="background-color:transparent;width:100%;min-height:500px;padding-left:5px;" allowtransparency="true" frameborder="0"></iframe>

            </div>
            <!-- /page content -->
            <div class="clearfix"></div>
            <!-- footer content -->
            <!--<footer>
                <div class="pull-right">
                    版权所有
                </div>
                <div class="clearfix"></div>
            </footer>-->
            <!-- /footer content -->

            <audio id="chatAudio" style="display:none;" ><source src="css/default.mp3" type="audio/mpeg" /></audio>
        </div>
    </div>
    <!-- jQuery -->
    <script src="Scripts/jquery-1.11.2.min.js"></script>
    <!-- Bootstrap -->
    <script src="Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="Scripts/layer/layer.js"></script>
    <script src="Scripts/plugins/custom.js"></script>
    <script src="Scripts/ComFunJS.js?bwver=2016112802"></script>
    <script src="Scripts/avalon2.js"></script>
    <script src="Scripts/toastr.js"></script>
    <script src="Scripts/echarts.min.js"></script>
    <script type="text/javascript">
        var layerr;
        var model = avalon.define({
            $id: "indexvm",
            muData: [],
            nowPage: "indexpage.html",
            newPageName: "",
            GetMUData: function () {
                $.getJSON(ComFunJS.APIURL("BASE_GETMENU"), function (r) {
                    if (r.error == "") {
                        model.muData = r.result;
                    }

                })
            },
            OpenHome: function (url) {
                if (model.muData.length > 0) {
                    model.nowPage = url + "?r=" + Math.random();
                    model.newPageName = "";
                }
            },
            OpenUrl: function (el) {
                if (el) {
                    model.newPageName = el.MenuTxt;
                    if (el.MenuUrl.indexOf("?") > 0) {
                        model.nowPage = el.MenuUrl + "&r=" + Math.random();
                    } else {
                        model.nowPage = el.MenuUrl + "?r=" + Math.random();
                    }
                }
            },
            ChangePwd: function () {
                top.ComFunJS.winShowForm("/admin/BASE/BASE_ADD.html?FunCode=CHNPWD", "修改密码",500,300);
            },
            LoginOut: function () {
                ComFunJS.showConfirm("确认退出吗？", function () {
                    ComFunJS.delToken();
                    window.location = "../login.html";
                }, "退出");
            },
            GetError: function () {
                $.getJSON(ComFunJS.APIURL("BASE_GETERROR"), function (r) {
 
                    if (r.error == "" && r.result.length > 0) {

                        var emsg = ' <table class="table">';
                        emsg+='<thead><tr><th>设备名称</th><th>通道名称</th><th>状态</th><th>值</th><th>检测时间</th></tr></thead>';
                        emsg += '<tbody>';
                        
                        r.result.forEach(function (item, index) {
                            emsg += '<tr style="color:red;"><td>' + item.EquName + '</td><td>' + item.PathName + '</td><td>' + item.PathStatus + '</td><td>' + item.PathData + '</td><td>' + item.FlagTime + '</td></tr>';

                        })

                        emsg += '</tbody></table>';


                       $('#chatAudio')[0].play();
                       if (layerr) {
                          // layer.close(layerr);
                           $("#divemsg").html(emsg);

                       } else {

                           layerr = layer.open({
                               //title:["报警信息",'color:red'],
                               title: false,
                               closeBtn: 0,
                               type: 1
                          , offset: 'rb' //具体配置参考：offset参数项
                          , content: '<div id="divemsg">' + emsg + '</div>'
                               , btn: '关闭'
                               //, btnAlign: 'c' //按钮居中
                          , shade: 0 //不显示遮罩
                          ,area: ['600px', '300px']
                          , yes: function () {
                              layer.closeAll();
                              layerr = null;
                          }

                           });

                       }
                       

                    } else {
                        if (layerr) {
                            layer.closeAll();
                            layerr = null;
                        }

                    }

                })

                
            },
            UserModel: {}
        });
        avalon.ready(function () {
            if (ComFunJS.getToken()) {
                model.GetMUData();

                $.getJSON(ComFunJS.APIURL("BASE_GETUSERINFO"), function (r) {
                    if (r.error == "") {
                        model.UserModel = r.result;
                    }
                });

                setInterval("model.GetError()", 10000);
            }
            else {
                window.location.href = "../login.html";
            }
        })
    </script>

</body>
</html>
